package server;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import autofactory.UpdateManager;
import model.UserInfoBase;
import page.PageManagerSMSFactory;
import tools.NameTag;

public class UpdateContextServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter out=resp.getWriter();
		out.println("<html><body><h1>This is a servlet test UpdateContextServlet . welcome</h1></body></html>");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
		UpdateManager updateManager = (UpdateManager) req.getSession().getAttribute(NameTag.NAME_TAG_SESSION);
		if(updateManager != null){
			updateManager.build(req, resp);
		}
		req.getRequestDispatcher("main.jsp").forward(req, resp);
	}
	
}
